package com.example.job07.config;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

import java.util.Map;

@Slf4j
public class DynamicDatasource extends AbstractRoutingDataSource {

    /**
     * 用于存放当前应用使用的数据源链接信息
     */
    @Getter
    @Setter
    private Map<Object, Object> targetDataSourceMap;

    @Override
    protected Object determineCurrentLookupKey() {
        String dsKey = DataSourceContext.getRoutekey();
        return dsKey;
    }
}
